package com.sugar.subscribe.course.module.business.dal.mysql.coachservice;

import java.util.*;

import com.sugar.subscribe.course.framework.common.pojo.PageResult;
import com.sugar.subscribe.course.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.subscribe.course.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.subscribe.course.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.subscribe.course.module.business.controller.app.serviceclass.vo.AppServiceClassRespVO;
import com.sugar.subscribe.course.module.business.dal.dataobject.coachservice.CoachServiceDO;
import com.sugar.subscribe.course.module.business.dal.dataobject.serviceclass.ServiceClassDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.subscribe.course.module.business.controller.admin.coachservice.vo.*;

/**
 * 教练服务 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface CoachServiceMapper extends BaseMapperX<CoachServiceDO> {

    default PageResult<CoachServiceDO> selectPage(CoachServicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CoachServiceDO>()
                .eqIfPresent(CoachServiceDO::getCoachId, reqVO.getCoachId())
                .eqIfPresent(CoachServiceDO::getServicePId, reqVO.getServicePId())
                .eqIfPresent(CoachServiceDO::getServiceId, reqVO.getServiceId())
                .betweenIfPresent(CoachServiceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CoachServiceDO::getId));
    }

    default List<AppServiceClassRespVO> getCoachServiceClassByCoachId(Long coachId){
        return selectJoinList(AppServiceClassRespVO.class, new MPJLambdaWrapperX<CoachServiceDO>()
                .selectAll(ServiceClassDO.class)
                .leftJoin(ServiceClassDO.class, ServiceClassDO::getId, CoachServiceDO::getServiceId)
                .eq(CoachServiceDO::getCoachId, coachId));
    }
}